import '/@/design/index.less'
// 注册 windi
import 'virtual:windi-base.css'
import 'virtual:windi-components.css'
import 'virtual:windi-utilities.css'
import 'virtual:windi-devtools'
// 注册图标
import 'virtual:svg-icons-register'
import App from './App.vue'
import { createApp, nextTick } from 'vue'
import { initAppConfigStore } from '/@/logics/initAppConfig'
import { setupErrorHandle } from '/@/logics/error-handle'
import { router, setupRouter } from '/@/router'
import { setupRouterGuard } from '/@/router/guard'
import { setupStore } from '/@/store'
import { setupGlobDirectives } from '/@/directives'
import { setupI18n } from '/@/locales/setupI18n'
import { registerGlobComp } from '/@/components/registerGlobComp'
import 'ant-design-vue/dist/antd.less'
import { useMenuSetting } from '/@/hooks/setting/useMenuSetting'
import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting'
import { useMultipleTabSetting } from '/@/hooks/setting/useMultipleTabSetting'
import { useUserStore } from "/@/store/modules/user";
// 在本地开发中引入的,以提高浏览器响应速度
async function bootstrap() {
	// 创建应用实例
	const app = createApp(App)
	// 多语言配置,异步情况:语言文件可以从服务器端获得
	await setupI18n(app)

	// 配置存储
	setupStore(app)

	const userStore = useUserStore()
	await userStore.afterLoginAction(false, {})

	// 初始化内部系统配置
	initAppConfigStore()

	// 注册全局组件
	registerGlobComp(app)

	//CAS单点登录
	// await useSso().ssoLogin();

	// 配置路由
	setupRouter(app)

	// 路由保护
	setupRouterGuard(router)

	// 注册全局指令
	setupGlobDirectives(app)

	// 配置全局错误处理
	setupErrorHandle(app)

	// 当路由准备好时再执行挂载( https://next.router.vuejs.org/api/#isready)
	await router.isReady()
	// 挂载应用
	app.mount('#app', true)
}

bootstrap()

// nextTick(() => {
// 	const { setMenuSetting } = useMenuSetting()

// 	const { setHeaderSetting } = useHeaderSetting()

// 	const { setMultipleTabSetting } = useMultipleTabSetting()

// 	setTimeout(() => {
// 		setMenuSetting({
// 			show: true,
// 		})
// 		setHeaderSetting({
// 			show: true,
// 		})
// 		setMultipleTabSetting({
// 			show: true,
// 		})
// 	}, 1000)
// })
